import { get, post } from '@/utils/request.js'
import Config from '@/config'

export default {
  getBaseInfo(id) {
    return get(Config.API_VERSION + '/ServicePrice/GetQuoteList', { clientID: id })
  },
  // 获取可选BUM
  getBumCandidates(id) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuoteApplyBUMS', { clientID: id }, false, false, {
      ccid: id
    })
  },
  // 获取当前客户可用的语言对
  getLanguagePair(id, fromGrad) {
    return get(
      Config.API_VERSION + '/ServicePrice/GetQuoteApplyMayChooseLangPair',
      {
        clientID: id,
        fromGrad: fromGrad
      },
      false,
      false,
      { ccid: id }
    )
  },
  // 检查是否可以创建申请单
  isAvailableToCreateApply(id) {
    return get(Config.API_VERSION + '/ServicePrice/VerifyClientQuoteApply', {
      clientID: id
    })
  },
  // 获取需求内容
  getDemandTypesContent(pid) {
    return get('/Dict/CBGDemandType', { PID: pid })
  },
  // 创建申请单
  createQuoteApply(id, base, attach) {
    base.clientID = id
    base.attch = attach
    return post(Config.API_VERSION + '/ServicePrice/CreateClientQuoteApply', base)
  },
  // 更新申请单
  updateQuoteApply(applyId, data) {
    data.applyID = applyId
    return post(Config.API_VERSION + '/ServicePrice/UpdateClientQuoteApply', data)
  },
  // 提交申请单
  submitQuoteApply(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/SubmitClientQuoteApply', { applyID })
  },
  // 撤回申请单
  revokeQuoteApply(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/RevokeClientQuoteApply', { applyID })
  },
  // 删除申请单
  deleteQuoteApply(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/DeleteClientQuoteApply', { applyID })
  },
  // 获取申请单详情
  getQuoteApply(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuoteApply', { applyID })
  },
  // 获取申请单操作记录
  getOperationLog(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuoteApplyOperationLog', { applyID })
  },
  // 确认价格
  confirmPrice(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/ConfirmClientQuoteApply', { applyID })
  },
  // 请求修改
  applyModify(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/ApplyModifyClientQuoteApply', { applyID })
  },
  // 获取协议价格
  getNegotiatedPrice(clientID) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuote', { clientID })
  },
  // 导出全部协议价格
  exportAllNegotiatedPrice(clientID) {
    return get(Config.API_VERSION + '/ServicePrice/ExportClientQuote', { clientID }, false, true)
  },
  // 导出申请单
  exportQuota(applyID) {
    return get(Config.API_VERSION + '/ServicePrice/ExportClientQuoteApply', { applyID }, false, true)
  },
  // 获取已存在Quotation
  getExistQuotation(clientID) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuotationList', { clientID })
  },
  // 创建Quotation
  createFromQuotation(clientID, qpvID) {
    return get(Config.API_VERSION + '/ServicePrice/CreateClientQuoteByQuotation', { clientID, qpvID })
  },
  // 获取价格管理员
  getPriceManagers(clientID) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuoteApplyAdminPrices', { clientID })
  },
  // 保存价格管理员
  savePriceManager(applyId, managerId) {
    return get(Config.API_VERSION + '/ServicePrice/SaveClientQuoteApplyAdminPrice', {
      applyID: applyId,
      EmpID: managerId
    })
  },
  // 提交至价格管理员
  sendToPriceManager(applyId) {
    return get(Config.API_VERSION + '/ServicePrice/SubmitAPClientQuoteApply', {
      applyID: applyId
    })
  },
  // BUM获取所有服务类型
  getAllServiceType() {
    return get(Config.API_VERSION + '/ServicePrice/GetClientQuoteApplyServiceType', {})
  },
  // BUM保存服务类型
  saveServiceTypes(applyID, data) {
    return post(Config.API_VERSION + '/ServicePrice/SaveClientQuoteApplyServiceType', {
      apply: applyID,
      serviceTypes: data
    })
  },
  // BUM保存客户价值系数
  saveClientQuoteApplyValue(id, applyId, data) {
    data.client = id
    data.apply = applyId
    return post(Config.API_VERSION + '/ServicePrice/SaveClientCBGValue', data)
  },
  // BUM保存服务价格
  savePrice(data) {
    return post(Config.API_VERSION + '/ServicePrice/SaveClientQuoteApplyServicePrice', data)
  },
  // BUM增加语言对
  addLanguagePairs(applyId, languagePairs) {
    return post(Config.API_VERSION + '/ServicePrice/AddClientQuoteApplyLangPair', {
      apply: applyId,
      langPairID: languagePairs
    })
  },
  // BUM删除语言对
  deleteLanguagePairs(applyId, sLang, tLang) {
    return post(Config.API_VERSION + '/ServicePrice/DeleteClientQuoteApplyLangPair', {
      apply: applyId,
      sLang,
      tLang
    })
  },
  // BUM确认报价单
  completeApply(applyId) {
    return get(Config.API_VERSION + '/ServicePrice/CompleteClientQuoteApply', { applyId })
  },
  // BUM退回报价单
  returnApply(applyId) {
    return get(Config.API_VERSION + '/ServicePrice/RejectClientQuoteApply', { applyId })
  },
  // 价格管理员通过申请单
  passQuoteApply(applyId) {
    return get(Config.API_VERSION + '/ServicePrice/CompleteAPClientQuoteApply', { applyId })
  }
}
